#include "echo_service.h"

void EchoServiceImpl::Echo(google::protobuf::RpcController *controller,
                           const EchoRequestPB *request,
                           EchoResponsePB *response,
                           google::protobuf::Closure *done)
{
    std::cout << "EchoServiceImpl::Echo" << request->message() << std::endl;
    response->set_message(request->message());
    if (done != nullptr)
    {
        done->Run();
    }
}

void EchoServiceImpl::Add(google::protobuf::RpcController *controller,
                          const AddRequestPB *request,
                          AddResponsePB *response,
                          google::protobuf::Closure *done)
{
    // 获取请求数据中的 2 个整型数据
    int32_t a = request->a();
    int32_t b = request->b();

    // 计算结果，然后放入响应数据中
    response->set_result(a + b);

    done->Run();
}
